//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows;

namespace OpenLS.Spreadsheet.UI.Internals
{
    using conv = System.Convert;
    class IntToThicknessConverter: IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            return new Thickness(
                ConvertToDouble(values[0]),
                ConvertToDouble(values[1]),
                ConvertToDouble(values[2]),
                ConvertToDouble(values[3]));
            }

        private static double ConvertToDouble(object o)
        {
            if (o is Thickness)
                return 0.0;
            return conv.ToDouble(o);
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
